import * as Types from 'containers/ActionTypes';

export default function (state = { isMobile: false }, action) {
  switch (action.type) {
  case Types.ROOT.DETECT_ENVIRONMENT:
    return Object.assign({}, state, {
      isMobile: action.isMobile,
    });
  case Types.ROOT.RECEIVE_CATEGORIES:
    return Object.assign({}, state, {
      categories: action.categories,
    });
  case Types.ROOT.TOGGLE_SIDEBAR:
    var sidebarVisibility = state.sidebarVisibility;
    return Object.assign({}, state, {
      sidebarVisibility: !sidebarVisibility,
    });
  case Types.ROOT.HIDE_SIDEBAR:
    return Object.assign({}, state, {
      sidebarVisibility: false,
    });
  default:
    return state;
  }
}
